home *** CD-ROM | disk | FTP | other *** search
/ Chip 1996 November / CHIP Kasım 1996.iso / ms / webpost / wpsdk.exe / RCDATA / CABINET / SITE.CPP < prev    next >
C/C++ Source or Header  |  1996-07-08  |  12KB  |  582 lines

  1. /*****************************************************************/
  2. /**               Microsoft Windows 4.00                        **/
  3. /**           Copyright (C) Microsoft Corp., 1995-1996          **/
  4. /*****************************************************************/
  5.  
  6. /* SITE.CPP - Methods for SITE class
  7.  *
  8.  * History:
  9.  *  02/20/96    vlads   Created
  10.  *
  11.  */
  12.  
  13. #include "wbprov.h"
  14.  
  15. WPPSiteA::WPPSiteA(LPCSTR lpszSiteName, LPCSTR lpszURL)
  16.     : m_cRef(1),
  17.       m_fValid(FALSE),
  18.       m_pDefaultSite(NULL)
  19. {
  20.     // Constructor logic
  21.     m_fValid = TRUE;
  22.  
  23.      // Get default site object
  24.     //m_pDefaultSite = WPPCreateDefaultSite(lpszSiteName, lpszURL);
  25. }
  26.  
  27. WPPSiteA::~WPPSiteA(void)
  28. {
  29.  
  30.      // If default pointer was obtained - release it
  31.        if (m_pDefaultSite) {
  32.          m_pDefaultSite->Release();
  33.      }
  34.  
  35.     // Destructor and clean up
  36.     m_fValid = FALSE;
  37. }
  38.  
  39.  
  40. WPPSiteW::WPPSiteW(LPCWSTR lpszSiteName, LPCWSTR lpszURL)
  41.     : m_cRef(1),
  42.       m_fValid(FALSE),
  43.       m_pDefaultSite(NULL)
  44. {
  45.     // Constructor logic
  46.     m_fValid = TRUE;
  47.  
  48.     // Should create a WPPSiteA object
  49.     
  50.      // Get default site object
  51.     //m_pDefaultSite = WPPCreateDefaultSite(lpszSiteName, lpszURL);
  52. }
  53.  
  54. WPPSiteW::~WPPSiteW(void)
  55. {
  56.  
  57.      // If default pointer was obtained - release it
  58.        if (m_pDefaultSite) {
  59.          m_pDefaultSite->Release();
  60.      }
  61.  
  62.     // Destructor and clean up
  63.     m_fValid = FALSE;
  64. }
  65.  
  66.  
  67. //
  68. // GLobal object generator function
  69. //
  70. dllexp
  71. HRESULT
  72. WINAPI
  73. WppBindToSiteA(
  74.     HWND    hwnd,
  75.     LPCSTR    lpszSiteName,
  76.     LPCSTR lpszURL,
  77.     REFIID     riid,
  78.     DWORD    dwFlag,
  79.     DWORD    dwReserved,
  80.     PVOID * ppvObj)
  81. {
  82.  
  83.     WPPSiteA *pSite = NULL;
  84.  
  85.     // Check requested interface ID
  86.     if (!IsEqualIID(riid, IID_IUnknown) &&
  87.         !IsEqualIID(riid, IID_IWPSite)) {
  88.         return ResultFromScode(E_NOINTERFACE);
  89.     }
  90.  
  91.     // This sample provider will handle URL 
  92.     // http://wbprov
  93.     if (!(dwFlag & WPF_FORCE_BIND))
  94.     {
  95.         if (!(lpszURL && !lstrcmpi(lpszURL, "http://wbprov")))
  96.             return ResultFromScode(E_INVALIDARG);
  97.     }
  98.         
  99.     // Create instance of object
  100.     pSite = new WPPSiteA(NULL,lpszURL);
  101.  
  102.     // Was it sucessful ?
  103.     if (!pSite || !pSite->IsValid()) {
  104.         return ResultFromScode(E_OUTOFMEMORY);
  105.     }
  106.  
  107.     *ppvObj = pSite;
  108.     return NOERROR;
  109. }
  110.  
  111.  
  112. dllexp
  113. HRESULT
  114. WINAPI
  115. WppListSitesA(
  116.     LPDWORD            lpcbSites,
  117.     LPWPSITEINFOA    lpSiteInfo,
  118.     LPDWORD            lpcSites)
  119. {
  120.     return ResultFromScode(E_NOTIMPL);
  121. }
  122.  
  123.  
  124. dllexp 
  125. HRESULT 
  126. WINAPI
  127. WppDeleteSiteA(
  128.     LPCSTR    lpszSiteName)
  129. {
  130.     return ResultFromScode(E_NOTIMPL);
  131. }
  132.  
  133.  
  134. //
  135. // GLobal object generator function
  136. //
  137. dllexp
  138. HRESULT
  139. WINAPI
  140. WppBindToSiteW(
  141.     HWND    hwnd,
  142.     LPCWSTR    lpszSiteName,
  143.     LPCWSTR lpszURL,
  144.     REFIID     riid,
  145.     DWORD    dwFlag,
  146.     DWORD    dwReserved,
  147.     PVOID * ppvObj)
  148. {
  149.     return ResultFromScode(E_NOTIMPL);
  150. }
  151.  
  152.  
  153. dllexp
  154. HRESULT
  155. WINAPI
  156. WppListSitesW(
  157.     LPDWORD            lpcbSites,
  158.     LPWPSITEINFOW    lpSiteInfo,
  159.     LPDWORD            lpcSites)
  160. {
  161.     return ResultFromScode(E_NOTIMPL);
  162. }
  163.  
  164.  
  165. dllexp 
  166. HRESULT 
  167. WINAPI
  168. WppDeleteSiteW(
  169.     LPCWSTR    lpszSiteName)
  170. {
  171.     return ResultFromScode(E_NOTIMPL);
  172. }
  173.  
  174.  
  175. //
  176. // *** IUnknown methods ***
  177. //
  178.  
  179. STDMETHODIMP WPPSiteA::QueryInterface(REFIID riid, LPVOID * ppvObj)
  180. {
  181.     if (!IsEqualIID(riid, IID_IUnknown) &&
  182.         !IsEqualIID(riid, IID_IWPSite)) {
  183.         return ResultFromScode(E_NOINTERFACE);
  184.     }
  185.  
  186.     *ppvObj = this;
  187.     AddRef();
  188.     return NOERROR;
  189. }
  190.  
  191. STDMETHODIMP_(ULONG) WPPSiteA::AddRef(void)
  192. {
  193.     return ++m_cRef;
  194. }
  195.  
  196. STDMETHODIMP_(ULONG) WPPSiteA::Release(void)
  197. {
  198.     ULONG cRef;
  199.  
  200.     cRef = --m_cRef;
  201.  
  202.     if (0L == m_cRef) {
  203.         delete this;
  204.     }
  205.  
  206.     return cRef;
  207. }
  208.  
  209.  
  210. STDMETHODIMP WPPSiteW::QueryInterface(REFIID riid, LPVOID * ppvObj)
  211. {
  212.     if (!IsEqualIID(riid, IID_IUnknown) &&
  213.         !IsEqualIID(riid, IID_IWPSite)) {
  214.         return ResultFromScode(E_NOINTERFACE);
  215.     }
  216.  
  217.     *ppvObj = this;
  218.     AddRef();
  219.     return NOERROR;
  220. }
  221.  
  222. STDMETHODIMP_(ULONG) WPPSiteW::AddRef(void)
  223. {
  224.     return ++m_cRef;
  225. }
  226.  
  227. STDMETHODIMP_(ULONG) WPPSiteW::Release(void)
  228. {
  229.     ULONG cRef;
  230.  
  231.     cRef = --m_cRef;
  232.  
  233.     if (0L == m_cRef) {
  234.         delete this;
  235.     }
  236.  
  237.     return cRef;
  238. }
  239.  
  240.  
  241. //
  242. // *** IWPSite methods ***
  243. //
  244.  
  245. STDMETHODIMP WPPSiteA::NetworkConnect (LPCSTR lpszUserName,
  246.                               LPCSTR lpszPassword)
  247. {
  248.     OutputDebugString("WBPROV: NetworkConnect");
  249.     OutputDebugString("\r\n");
  250.     return NOERROR;
  251.  
  252. #if 0
  253.    if (m_pDefaultSite) {
  254.        return(m_pDefaultSite->NetworkConnect(lpszUserName,lpszPassword));
  255.     }
  256.  
  257.    return ResultFromScode(E_NOTIMPL);
  258. #endif
  259. }
  260.  
  261. STDMETHODIMP WPPSiteA::NetworkDisconnect ()
  262. {
  263.     OutputDebugString("WBPROV: NetworkDisconnect");
  264.     OutputDebugString("\r\n");
  265.     return NOERROR;
  266.  
  267. #if 0
  268.    if (m_pDefaultSite) {
  269.        return(m_pDefaultSite->NetworkDisconnect());
  270.     }
  271.  
  272.     return ResultFromScode(E_NOTIMPL);
  273. #endif
  274. }
  275.  
  276. STDMETHODIMP WPPSiteA::ServerLogin (LPCSTR lpszUserName,
  277.                               LPCSTR lpszPassword)
  278. {
  279.     OutputDebugString("WBPROV: ServerLogin");
  280.     OutputDebugString("\r\n");
  281.     return NOERROR;
  282.  
  283. #if 0
  284.    if (m_pDefaultSite) {
  285.        return(m_pDefaultSite->ServerLogin(lpszUserName,lpszPassword));
  286.     }
  287.  
  288.    return ResultFromScode(E_NOTIMPL);
  289. #endif
  290. }
  291.  
  292. STDMETHODIMP WPPSiteA::ServerLogout ()
  293. {
  294.     OutputDebugString("WBPROV: ServerLogout");
  295.     OutputDebugString("\r\n");
  296.     return NOERROR;
  297.  
  298. #if 0
  299.    if (m_pDefaultSite) {
  300.        return(m_pDefaultSite->ServerLogout());
  301.     }
  302.  
  303.    return ResultFromScode(E_NOTIMPL);
  304. #endif
  305. }
  306.  
  307. STDMETHODIMP WPPSiteA::GetSiteInfo (
  308.                         LPWPSITEINFOA lpSiteInfo,
  309.                         LPDWORD lpcbSiteInfo)
  310.  
  311. {
  312.     OutputDebugString("WBPROV: GetSiteInfo");
  313.     OutputDebugString("\r\n");
  314.  
  315.    if (m_pDefaultSite) {
  316.        return(m_pDefaultSite->GetSiteInfo (lpSiteInfo,lpcbSiteInfo));
  317.     }
  318.  
  319.    return ResultFromScode(E_NOTIMPL);
  320. }
  321.  
  322. STDMETHODIMP WPPSiteA::PostFiles(DWORD     cLocalPaths,
  323.                         LPSTR     *lppszLocalPaths,
  324.                         LPDWORD    lpcbURL,
  325.                         LPSTR    lpszURL,
  326.                         DWORD     dwFlag)
  327.  
  328. {
  329.     OutputDebugString("WBPROV: PostFiles");
  330.     OutputDebugString("\r\n");
  331.     return NOERROR;
  332.  
  333. #if 0
  334.    if (m_pDefaultSite) {
  335.        return(m_pDefaultSite->PostFiles(cLocalPaths,
  336.                                        lppszLocalPaths,
  337.                                        lpcbURL,
  338.                                        lpszURL,
  339.                                        dwFlag));
  340.     }
  341.  
  342.    return ResultFromScode(E_NOTIMPL);
  343. #endif
  344. }
  345.  
  346. STDMETHODIMP WPPSiteA::Commit ()
  347. {
  348.     OutputDebugString("WBPROV: Commit");
  349.     OutputDebugString("\r\n");
  350.  
  351.    if (m_pDefaultSite) {
  352.        return(m_pDefaultSite->Commit());
  353.     }
  354.  
  355.     return ResultFromScode(E_NOTIMPL);
  356.     
  357. }
  358.  
  359. STDMETHODIMP WPPSiteA::GetParam(LPCSTR     lpszParameter,
  360.                            LPDWORD    lpcchValue,
  361.                            LPSTR    lpszValue)
  362.  
  363. {
  364.     OutputDebugString("WBPROV: GetParam");
  365.     OutputDebugString("\r\n");
  366.  
  367.    if (m_pDefaultSite) {
  368.        return(m_pDefaultSite->GetParam(lpszParameter,
  369.                                       lpcchValue,
  370.                                       lpszValue));
  371.     }
  372.  
  373.    return ResultFromScode(E_NOTIMPL);
  374.     
  375. }
  376.  
  377. STDMETHODIMP WPPSiteA::SetParam(LPCSTR    lpszParameter,
  378.                            LPCSTR  lpszValue)
  379.  
  380. {
  381.     OutputDebugString("WBPROV: SetParam");
  382.     OutputDebugString("\r\n");
  383.  
  384.    if (m_pDefaultSite) {
  385.        return(m_pDefaultSite->SetParam(lpszParameter,
  386.                                       lpszValue));
  387.     }
  388.  
  389.     return ResultFromScode(E_NOTIMPL);
  390.     
  391. }
  392.  
  393. STDMETHODIMP WPPSiteA::GetError (
  394.                             LPDWORD    lpdwErrorType,
  395.                             LPDWORD    lpdwErrorCode,
  396.                             LPDWORD    lpcbError,
  397.                             LPTSTR    lpszError) 
  398. {
  399.     OutputDebugString("WBPROV: GetError");
  400.     OutputDebugString("\r\n");
  401.  
  402.     return ResultFromScode(E_NOTIMPL);
  403. }
  404.  
  405. STDMETHODIMP WPPSiteA::DeleteFile (
  406.                             LPCTSTR    lpszFile)
  407. {
  408.     OutputDebugString("WBPROV: DeleteFile");
  409.     OutputDebugString("\r\n");
  410.     return ResultFromScode(E_NOTIMPL);
  411. }
  412.  
  413. STDMETHODIMP WPPSiteA::FindFirstFile (
  414.                                 LPCTSTR lpszSearchFile,
  415.                                 LPWIN32_FIND_DATA lpFindFileData,
  416.                                 LPHANDLE lpSearchHandle)
  417. {
  418.     OutputDebugString("WBPROV: FindFirstFile");
  419.     OutputDebugString("\r\n");
  420.     return ResultFromScode(E_NOTIMPL);
  421. }
  422.  
  423. STDMETHODIMP WPPSiteA::FindNextFile (
  424.                                 HANDLE hSearchHandle,
  425.                                 LPWIN32_FIND_DATA lpFindFileData)
  426. {
  427.     OutputDebugString("WBPROV: FindNextFile");
  428.     OutputDebugString("\r\n");
  429.     return ResultFromScode(E_NOTIMPL);
  430. }
  431.  
  432. STDMETHODIMP WPPSiteA::FindClose (
  433.                             HANDLE hSearchHandle)
  434. {
  435.     OutputDebugString("WBPROV: FindClose");
  436.     OutputDebugString("\r\n");
  437.     return ResultFromScode(E_NOTIMPL);
  438. }    
  439.  
  440.  
  441. //
  442. // *** IWPSite methods ***
  443. //
  444.  
  445. STDMETHODIMP WPPSiteW::NetworkConnect (LPCWSTR lpszUserName,
  446.                               LPCWSTR lpszPassword)
  447. {
  448.     OutputDebugString("WPPSiteW: NetworkConnect");
  449.     OutputDebugString("\r\n");
  450.     // Convert to Ansi and call the corresponding A functions
  451.     return ResultFromScode(E_NOTIMPL);
  452.  
  453. }
  454.  
  455. STDMETHODIMP WPPSiteW::NetworkDisconnect ()
  456. {
  457.     OutputDebugString("WPPSiteW: NetworkDisconnect");
  458.     OutputDebugString("\r\n");
  459.     // Convert to Ansi and call the corresponding A functions
  460.     return ResultFromScode(E_NOTIMPL);
  461. }
  462.  
  463. STDMETHODIMP WPPSiteW::ServerLogin (LPCWSTR lpszUserName,
  464.                               LPCWSTR lpszPassword)
  465. {
  466.     OutputDebugString("WPPSiteW: ServerLogin");
  467.     OutputDebugString("\r\n");
  468.     // Convert to Ansi and call the corresponding A functions
  469.     return ResultFromScode(E_NOTIMPL);
  470. }
  471.  
  472. STDMETHODIMP WPPSiteW::ServerLogout ()
  473. {
  474.     OutputDebugString("WPPSiteW: ServerLogout");
  475.     OutputDebugString("\r\n");
  476.     // Convert to Ansi and call the corresponding A functions
  477.     return ResultFromScode(E_NOTIMPL);
  478. }
  479.  
  480. STDMETHODIMP WPPSiteW::GetSiteInfo (
  481.                         LPWPSITEINFOW lpSiteInfo,
  482.                         LPDWORD lpcbSiteInfo)
  483.  
  484. {
  485.     OutputDebugString("WPPSiteW: GetSiteInfo");
  486.     OutputDebugString("\r\n");
  487.     // Convert to Ansi and call the corresponding A functions
  488.        return ResultFromScode(E_NOTIMPL);
  489. }
  490.  
  491. STDMETHODIMP WPPSiteW::PostFiles(DWORD     cLocalPaths,
  492.                         LPWSTR     *lppszLocalPaths,
  493.                         LPDWORD    lpcbURL,
  494.                         LPWSTR    lpszURL,
  495.                         DWORD     dwFlag)
  496.  
  497. {
  498.     OutputDebugString("WPPSiteW: PostFiles");
  499.     OutputDebugString("\r\n");
  500.     // Convert to Ansi and call the corresponding A functions
  501.     return ResultFromScode(E_NOTIMPL);
  502. }
  503.  
  504. STDMETHODIMP WPPSiteW::Commit ()
  505. {
  506.     OutputDebugString("WPPSiteW: Commit");
  507.     OutputDebugString("\r\n");
  508.     return ResultFromScode(E_NOTIMPL);
  509. }
  510.  
  511. STDMETHODIMP WPPSiteW::GetParam(LPCWSTR     lpszParameter,
  512.                            LPDWORD    lpcchValue,
  513.                            LPWSTR    lpszValue)
  514.  
  515. {
  516.     OutputDebugString("WPPSiteW: GetParam");
  517.     OutputDebugString("\r\n");
  518.     // Convert to Ansi and call the corresponding A functions
  519.     return ResultFromScode(E_NOTIMPL);
  520. }
  521.  
  522. STDMETHODIMP WPPSiteW::SetParam(LPCWSTR    lpszParameter,
  523.                            LPCWSTR  lpszValue)
  524.  
  525. {
  526.     OutputDebugString("WPPSiteW: SetParam");
  527.     OutputDebugString("\r\n");
  528.     // Convert to Ansi and call the corresponding A functions
  529.     return ResultFromScode(E_NOTIMPL);    
  530. }
  531.  
  532. STDMETHODIMP WPPSiteW::GetError (
  533.                             LPDWORD    lpdwErrorType,
  534.                             LPDWORD    lpdwErrorCode,
  535.                             LPDWORD    lpcbError,
  536.                             LPWSTR    lpszError) 
  537. {
  538.     OutputDebugString("WPPSiteW: GetError");
  539.     OutputDebugString("\r\n");
  540.     // Convert to Ansi and call the corresponding A functions
  541.     return ResultFromScode(E_NOTIMPL);
  542. }
  543.  
  544. STDMETHODIMP WPPSiteW::DeleteFile (
  545.                             LPCWSTR    lpszFile)
  546. {
  547.     OutputDebugString("WPPSiteW: DeleteFile");
  548.     OutputDebugString("\r\n");
  549.     // Convert to Ansi and call the corresponding A functions
  550.     return ResultFromScode(E_NOTIMPL);
  551. }
  552.  
  553. STDMETHODIMP WPPSiteW::FindFirstFile (
  554.                                 LPCWSTR lpszSearchFile,
  555.                                 LPWIN32_FIND_DATAW lpFindFileData,
  556.                                 LPHANDLE lpSearchHandle)
  557. {
  558.     OutputDebugString("WPPSiteW: FindFirstFile");
  559.     OutputDebugString("\r\n");
  560.     // Convert to Ansi and call the corresponding A functions
  561.     return ResultFromScode(E_NOTIMPL);
  562.  
  563. STDMETHODIMP WPPSiteW::FindNextFile (
  564.                                 HANDLE hSearchHandle,
  565.                                 LPWIN32_FIND_DATAW lpFindFileData)
  566. {
  567.     OutputDebugString("WPPSiteW: FindNextFile");
  568.     OutputDebugString("\r\n");
  569.     // Convert to Ansi and call the corresponding A functions
  570.     return ResultFromScode(E_NOTIMPL);
  571. }
  572.  
  573. STDMETHODIMP WPPSiteW::FindClose (
  574.                             HANDLE hSearchHandle)
  575. {
  576.     OutputDebugString("WPPSiteW: FindClose");
  577.     OutputDebugString("\r\n");
  578.     // Convert to Ansi and call the corresponding A functions
  579.     return ResultFromScode(E_NOTIMPL);
  580. }    
  581.